#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int cows = 0;
    ifstream ifs("outofplace.in");
    ifs >> cows;

    vector<int> heights(cows, 0);

    for(int i = 0; i < cows; ++i){
        ifs >> heights[i];
    }

    vector<int> sorted(heights);
    sort(sorted.begin(), sorted.end(), greater<int>());
    
    int result = 0;
    for(int i = 0; i < cows; ++i){
        if(sorted[i] != heights[i]){
            ++result;
        }
    }
    --result;

    ofstream ofs("outofplace.out");
    ofs << result;

    return 0;
}